package com.polaris.live.adapter

import com.blankj.utilcode.util.ColorUtils
import com.polaris.live.R
import com.polaris.live.common.R.color
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterHomeGameNumSelectBinding

/**
 * HomeGameNumAdapter
 *
 * @author Created by 半仙 on 2024/3/16/016 16:02
 */
class HomeGameNumAdapter : BaseBindingAdapter<AdapterHomeGameNumSelectBinding, Long>() {

    private var mSelectposition = 1

    override fun convert(holder: VBViewHolder<AdapterHomeGameNumSelectBinding>, item: Long) {
        holder.vb.apply {
            val position = holder.absoluteAdapterPosition
            if (position <= mSelectposition) {
                tvGameTypeCoin.setBackgroundColor(ColorUtils.getColor(R.color.color_9519f8))
                tvGameTypeCoin.setTextColor(ColorUtils.getColor(R.color.white))
            } else {
                tvGameTypeCoin.setBackgroundColor(ColorUtils.getColor(R.color.color_e6d1ff))
                tvGameTypeCoin.setTextColor(ColorUtils.getColor(color.color_202028))
            }
            tvGameTypeCoin.text = item.toString()
        }
    }

    fun setSelectPosition(position: Int) {
        mSelectposition = position
        notifyDataSetChanged()
    }

    fun getSelectPrice() = data[mSelectposition]

}